import request from '@/utils/request'

// 获取用户已有频道
export const userChannelListAPI = () => {
  return request({
    url: '/v1_0/user/channels'
  })
}
// 获取所有频道
export const allChannelListAPI = () => {
  return request({
    url: '/v1_0/channels',
    method: 'GET'
  })
}

// 重置频道(覆盖式保存)
export const setUserChannelAPI = (channelArr) => {
  return request({
    url: '/v1_0/user/channels',
    method: 'PUT',
    data: {
      channels: channelArr
    }
  })
}

// 删除频道
export const removeChannelAPI = (channelId) => {
  return request({
    url: `/v1_0/user/channels/${channelId}`,
    method: 'DELETE'
  })
}

// 搜索联想列表,自动补全
export const suggestListAPI = (keyWord) => {
  return request({
    url: '/v1_0/suggestion',
    params: {
      q: keyWord
    }
  })
}

// 获取搜索结果
export const searchResultListAPI = ({ page = 1, per_page = 10, keywords }) => {
  return request({
    url: '/v1_0/search',
    params: {
      page,
      per_page,
      q: keywords
    }
  })
}
